﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WLG.Model.Interface;
using WLG.Model.NotifyContext;

namespace WLG.Model
{
    public class ApplicationModel : IApplicationModel
    {
        private List<IObserver> _views = new List<IObserver>();
        private List<Notification> _Notifications = new List<Notification>();

        #region IObservable Members

        public void AddObserver(IObserver observer)
        {
            _views.Add(observer);
        }

        public void RemoveObserver(IObserver observer)
        {
            _views.Remove(observer);
        }

        public void NotifyObservers()
        {
            foreach (IApplicationModelObserver view in _views)
                view.Update(this);
        }

        #endregion

        #region IApplicationModel Members

        public List<Notification> Notifications
        {
            get
            {
                return _Notifications;
            }
            set
            {
                _Notifications = value;
                NotifyObservers();
            }
        }

        #endregion
    }
}
